<include file="Public/siteTopbar" />
    <link rel="stylesheet" href="__STATIC__/css/security_set.css">
    <link rel="stylesheet" href="__STATIC__/css/btn.css">
<link rel="stylesheet" href="__STATIC__/css/user.css" type="text/css">
    <script src="__STATIC__/js/jquery-1.10.2.min.js"></script>
    <script src="__STATIC__/js/slider.js"></script>
<include file="Public/header" />


<div class="container logintop">
<h3>My Account</h3>
<p>My Account allows you to manage your setting and preferences. Existing wish list or project portfolio logins can be used to login to My Account.</p>
</div>



<div class="container usercenter">
    <div class="col-sm-6">
        <div class="longinBox">
            <h3>- Forgot Your Password? -</h3>
                <ul class="form-list">

                    <li>
                    <select id="verify-type-selector" style="display: none;">
		<option value="email" selected alias-value="2">Email</option>
</select>


                         <label for="email" class="required"><em>*</em>Email Address:</label>
                         <input type="text" id="mobile" name="mobile" onBlur="chkuser()" placeholder="Verified email：{$userinfo.email}" readonly class="loginInput required-entry validate-email" title="Email Address">  

                    </li>
                    
                    
                    <li style="position:relative;">

                         <label for="email" class="required"><em>*</em>Code:</label>
                         <input type="text" id="tpcode" name="tpcode"  class="loginInput required-entry validate-email" >  
<input type="button" class="" style="width: 80px;height:38px;border:none; background:#630534; color:#fff; position:absolute; right:0; top:36px; border-radius:0 5px 5px 0;" id="sendSms" onclick="sendcode(this)" value="Send">
                    </li>
                   
                    <li>
                        <button type="button" class="loginbutton"   onClick="setpwd()"  ><span><span>Next step</span></span></button>
                    </li>
                </ul>
        </div>
    </div>
    
    
	<include file="forpass_public" />

</div>





<input type="hidden" id="username" value="{$userinfo.username}"> 
<div style="clear: both;"></div>
<include file="Public/footer" />
<script>
function sendcode(o){
	$.ajax({
		url:'/index.php?m=Home&c=User&a=send_validate_code&t='+Math.random(),
		type:'post',
		dataType:'json',
		data:{type:$('#verify-type-selector').val(),send:$('#username').val()},
		success:function(res){
			if(res.status==1){
				timer(o);
			}else{
				layer.msg(res.msg, {
					icon: 1,  
					time: 2000 
				});
			}
		}
	})
}

var wait=180;
function timer(o) { 
	//$('span[data-tips-for="tpcode"]').find('i').addClass('icon');
	//$('span[data-tips-for="tpcode"]').find('i').removeClass('icon-warn');
	//$('span[data-tips-for="tpcode"]').find('.txt').empty();
    if (wait == 0) {  
        o.removeAttribute("disabled");            
        o.value="Get verification code";  
        wait = 180;  
    } else {  
        o.setAttribute("disabled", true);  
        o.value="Send(" + wait + ")";  
        wait--;  
        setTimeout(function() {  
          timer(o)  
        }, 1000)  
    }  
}

var is_check = false;
function checkcode(){
	var tpcode = $('#tpcode').val();
	//$('span[data-tips-for="tpcode"]').css('display','inline');
	//$('span[data-tips-for="tpcode"]').find('i').removeClass('icon');
	//$('span[data-tips-for="tpcode"]').find('i').addClass('icon-warn');
	if(tpcode == ''){
		//$('span[data-tips-for="tpcode"]').find('.txt').empty().html('验证码不能为空');
		
				layer.msg('Verification code must be filled', {
					icon: 1,  
					time: 2000 
				});
		return;
	}
	if(tpcode.length != 4){
		//$('span[data-tips-for="tpcode"]').find('.txt').empty().html('验证码不正确');

				layer.msg('Incorrect verification code', {
					icon: 1,  
					time: 2000 
				});
		return;
	}
	
	$.ajax({
		url:'/index.php?m=Home&c=User&a=check_validate_code&t='+Math.random(),
		type:'post',
		dataType:'json',
		data:{code:tpcode,send:$('#username').val()},
		success:function(res){
			if(res.status==1){
				is_check = true;
				//$('span[data-tips-for="tpcode"]').css('display','inline');
				//$('span[data-tips-for="tpcode"]').find('i').removeClass('icon-warn');
				//$('span[data-tips-for="tpcode"]').find('i').addClass('icon-loss');
				//$('span[data-tips-for="tpcode"]').find('.txt').empty();
				window.location.href='/index.php?m=Home&c=User&a=set_pwd&t='+Math.random();
			}else{
				//$('span[data-tips-for="tpcode"]').find('.txt').empty().html(res.msg);

				layer.msg(res.msg, {
					icon: 1,  
					time: 2000 
				});
				//alert('验证码未验证通过');
				return false;				
			}
		}
	})
}

function setpwd(){
	var tpcode = $('#tpcode').val();
	//$('span[data-tips-for="tpcode"]').css('display','inline');
	//$('span[data-tips-for="tpcode"]').find('i').removeClass('icon');
	//$('span[data-tips-for="tpcode"]').find('i').addClass('icon-warn');
	if(tpcode == ''){
		//$('span[data-tips-for="tpcode"]').find('.txt').empty().html('验证码不能为空');

				layer.msg('verification code must be filled', {
					icon: 1,  
					time: 2000 
				});
		return;
	}
	if(tpcode.length != 4){
		//$('span[data-tips-for="tpcode"]').find('.txt').empty().html('验证码不正确');

				layer.msg('Incorrect verification code', {
					icon: 1,  
					time: 2000 
				});
		return;
	}
	
	checkcode();
 
}
</script>
</body>
</html>	